package com.example.imtoken.modules.private_import

import android.content.Intent
import android.view.View
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.ClickUtils
import com.example.imtoken.R
import com.example.imtoken.core.base.BaseActivity
import com.example.imtoken.databinding.ActivityPrivateImportBinding

class PrivateImportActivity :
    BaseActivity<PrivateImportViewModel, ActivityPrivateImportBinding>(PrivateImportViewModel::class.java) {

    private val importType by lazy {
        intent.getIntExtra("importType", 0)
    }

    private val passWord by lazy {
        intent.getStringExtra("passWord")
    }

    override fun initLayoutId(): Int {
        return R.layout.activity_private_import
    }

    override fun init() {
        initTitle()
        initClick()
        initView()
    }

    private fun initView() {
        when (importType) {
            1 -> {
                //导出KeyStore
                dataBinding.tvImportTips1.text = getString(R.string.privateImportTip1_1)
                dataBinding.tvImportTips2.text = getString(R.string.privateImportTip1_2)
                dataBinding.tvImportTips3.text = getString(R.string.privateImportTip1_3)
            }
            2 -> {
                //导出私钥
                dataBinding.tvImportTips1.text = getString(R.string.privateImportTip2_1)
                dataBinding.tvImportTips2.text = getString(R.string.privateImportTip2_2)
                dataBinding.tvImportTips3.text = getString(R.string.privateImportTip2_3)
            }
        }
    }

    private fun initClick() {
        dataBinding.include13.ivHeadBack.setOnClickListener {
            this.finish()
        }
        ClickUtils.applyGlobalDebouncing(dataBinding.tvNext) {
            val intent = Intent(this, PrivateImportCodeActivity::class.java)
            intent.putExtra("importType", importType)
            intent.putExtra("passWord", passWord)
            ActivityUtils.startActivity(intent)
            this.finish()
        }
    }

    private fun initTitle() {
        dataBinding.include13.vLine.visibility = View.INVISIBLE
    }
}